Skip to content

Adds more sample XSDs for testing (GML, SOAP-WSDL, Loc-ALTO), fixes yet more code generation bugs - #102

Merged
mamift merged 33 commits into
masterfrom
testing/gml
Sep 15, 2026
Merged

mamift merged 33 commits into
masterfrom
testing/gml

Conversation

@mamift

@mamift mamift commented Sep 9, 2026 •

Copy link
Copy Markdown
Owner
  • Adds more sample XSDs for testing (GML, SOAP-WSDL, LoC-ALTO)
  • Fixes a code generation bug (evidence: metalex.xsd and metalex_mcontainerTypeBug.xsd) that prevented properties on a base class for an XSD complex type from being generated properly and also the constructor for the derived class for a derived complex type passing arguments to a base constructor that had the wrong signature.
    • XObjectsCode/Src/XsdToTypesConverter.cs — in TraverseParticle, elements inherited through a restriction-derived base are no longer marked FromBaseType, since such a base contributes no generated members (its content model is deliberately skipped by BuildProperties). The derived type now generates the inherited content members itself, so its functional constructors initialize their own fields instead of forwarding to base(...) constructors that were never emitted.

v3.4.23

Junie's output:
```
### Summary
- Fixed a bug where simple types of `List` variety with enumerated item types (such as `fontStylesType` and `processingCategoryType` in the ALTO schema) were incorrectly identified as enum types, leading to broken validator references (`*Validator.TypeDefinition`), invalid `Enum.Parse` list getters, and non-compiling generated code.

### Changes
- Updated `SOMQueryExtensions.IsEnum` to return `false` for simple types of `XmlSchemaDatatypeVariety.List`. A list variety simple type is a sequence of values (represented in C# as `IList<T>`), not a CLR `enum`.
- Regenerated `GeneratedSchemaLibraries\ALTO\alto-4-4.xsd-g.cs` using the CLI tool with the corrected logic.
- Added a regression test (`T7_ListOfEnumsSimpleType_GeneratesCorrectValidatorAndProperties` in `EnumsCodeGenTest.cs`) verifying that list-of-enums simple types generate clean C# wrapper properties and validator classes without diagnostics.

### Verification
- Built the entire solution (`dotnet build LinqToXsd-TestingSuite.slnf`) cleanly with 0 errors.
- Verified that `ALTO.csproj` compiles cleanly with the regenerated `alto-4-4.xsd-g.cs`.
- Executed unit and regression tests (`fqn:Xml.Schema.Linq.Tests.EnumsCodeGenTest`), which passed successfully.
```
…SD string enums as the item type for an XSD List type. Double checked by junie.
@mamift
mamift marked this pull request as ready for review September 14, 2026 11:30
Copilot AI lite review requested due to automatic review settings September 14, 2026 11:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new Schema dependency traversal helpers in XObjectsCode/Schema.cs have confirmed crash/stack-overflow risks (null-splitting optional fields and recursive traversal without an effective visited set).

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR expands the repository’s “real-world” schema corpus (new GeneratedSchemaLibraries projects and XSD/config additions) to strengthen the compile-time gate, while also fixing several XSD→CLR/codegen/runtime edge-cases (restriction-derived base content handling, list-of-enums, and enum parsing) and extending the XSD import/include graph model to include reverse edges (IncludedBy/ImportedBy).

Changes:

  • Extend schema graph modelling: add IncludedBy/ImportedBy to the graph schema + populate reverse-edge metadata; rename entrypoint APIs to GetEntryPoint* and add graph connectivity/root helpers.
  • Fix code generation for restriction-derived-base scenarios and list-of-enums (including anonymous list-item enums) and add/extend tests covering these regressions.
  • Add new sample schema libraries (e.g., SOAP-WSDL, ALTO, GraffitiMarkupLanguage, Microsoft Search, MetaLEX repro assets) and bump version to 3.4.23.
File summaries
File Description
XObjectsTests/GraphTests.cs Updates graph expectations and adds new graph tests (reverse-edge + connectivity/root helpers).
XObjectsTests/EnumsCodeGenTest.cs Adds tests for list-of-enums codegen and runtime get/set behaviour.
XObjectsTests/ContentModelCodeGenTests.cs Adds regression coverage for restriction-base extension content members/ctors; relaxes diagnostic assertions.
XObjectsCore/SimpleTypeValidator.cs Improves enum facet matching by normalising non-string values via ToString().
XObjectsCore/API/XTypedServices.cs Adds enum parsing/convert pathways (incl. hyphen handling) to support list-of-enums scenarios.
XObjectsCode/XImportGraph.xsd-g.cs Regenerated import-graph types to include IncludedBy/ImportedBy elements.
XObjectsCode/XImportGraph.xsd Extends the graph schema to define IncludedBy/ImportedBy.
XObjectsCode/Src/XsdToTypesConverter.cs Fixes FromBaseType marking when base is restriction-derived (prevents invalid ctor forwarding).
XObjectsCode/Src/TypesToCodeDom.cs Adds enum emission support for list-of-anonymous-enum cases and adjusts nested enum handling for list enums.
XObjectsCode/Src/TypeBuilder.cs Ensures validator naming handles enums and list-of-anonymous-enum consistently.
XObjectsCode/Src/SOMQueryExtensions.cs Changes IsEnum semantics for list types; adds IsListOfEnums.
XObjectsCode/Src/ClrTypeReference.cs Adjusts CLR type resolution and validator naming for list-of-enums, including anonymous item types.
XObjectsCode/Src/ClrPropertyInfo.cs Treats local list-of-enum similarly to local enum for nested type handling.
XObjectsCode/Schema.cs Adds hand-written schema helper APIs (dependency traversal + IncludedBy/ImportedBy list helpers).
XObjectsCode/Graph.cs Adds graph-level helpers (connected/disconnected/root) and populates reverse edges; renames entrypoint APIs.
XObjectsCode/Extensions/GraphExtensions.cs Updates traversal extension to use renamed entrypoint API.
Version.props Bumps version to 3.4.23.
RELEASENOTES.md Adds 3.4.23 release notes entry.
LinqToXsd/Properties/launchSettings.json Adds a launch profile for SOAP-WSDL generation.
LinqToXsd.Schemas/LinqToXsd.Schemas.csproj Adds new GeneratedSchemaLibraries project references (ALTO, GML, SOAP-WSDL) and formatting tweak.
LinqToXsd-TestingSuite.slnf Adds new schema library projects to the testing suite filter.
GeneratedSchemaLibraries/XSD/W3C XMLSchema v1.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/XQueryX/XQueryX.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/XQueryX/xPathAxis_bug.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/XMLSpec/xmlspec.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Windows/windowsTaskSched.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/W3C.XML/xml.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/TraML/TraML1.0.0.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Toy schemas/Simple doc.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/ThermoML/je100999j_si_001.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/SharePoint2010/wss.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Rss/rss-2_0.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Pubmed/efetch-pubmed.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Pubmed/collections.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/ParaParserXml/ParaParseSchema.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/ParaParserXml/paraparse_xNameBug.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Opml/opml2.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/OFMX/OFMX-Snapshot.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/OcmContracts/v2/OcmContracts.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/OcmContracts/OcmContracts.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/NHS CDS/CDS-XML_Message_Root-V6-2-3.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/NestedChoiceTest/NestedChoiceTest.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/NameMangled/nameMangledSchemaStaticKeywords.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/mzQuantML/mzQuantML_1_0_0.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/mzIdentML/mzIdentML1.2.0.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Multi-namespaces/TestNs1.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/MSBuild/Microsoft.Build.xsd Fixes include schemaLocation filename to match existing Common types schema.
GeneratedSchemaLibraries/Microsoft.Expression.Media.Catalog/origin.md Adds provenance note for the schema source.
GeneratedSchemaLibraries/Microsoft.Expression.Media.Catalog/expression.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Microsoft Search/origin.md Adds provenance and acquisition note for Microsoft Search schemas.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Response.xsd.config Adds config mapping for Microsoft Search Response schemas.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Response.xsd Adds Response schema source files.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Response.Document.xsd Adds Document schema source files.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Registration.Response.xsd.config Adds config mapping for Registration Response schema.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Registration.Request.xsd.config Adds config mapping for Registration Request schema.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Registration.Request.xsd Adds Registration Request schema source files.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Query.xsd.config Updates Query config mappings and codegen settings.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Query.Office.Keywords.xsd.config Adds config for Office Keywords schema.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Query.Office.Keywords.xsd Adds Office Keywords schema source files.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Query.Office.Context.xsd.config Adds config for Office Context schema.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Query.Office.Context.xsd Adds Office Context schema source files.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Office.Parameters.xsd.config Adds config for ServiceParameters schema.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Office.Parameters.xsd Adds ServiceParameters schema source files.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Discovery.xsd.config Adds config for Discovery schema.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Search.Discovery.xsd Adds Discovery schema source files.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Office.ServiceParameters.xsd.config Adds config for Office ServiceParameters schema.
GeneratedSchemaLibraries/Microsoft Search/Microsoft.Office.ServiceParameters.xsd Adds Office ServiceParameters schema source files.
GeneratedSchemaLibraries/Microsoft Project 2007/origin.md Adds provenance note for Microsoft Project schemas.
GeneratedSchemaLibraries/Microsoft Project 2007/mspdi_pj12.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/MetaLEX/origin.md Adds provenance links for MetaLEX schemas.
GeneratedSchemaLibraries/MetaLEX/metalex.xsd.config Adds config for MetaLEX schema generation.
GeneratedSchemaLibraries/MetaLEX/metalex_mcontainerTypeBug.xsd.config Adds config for MetaLEX repro schema generation.
GeneratedSchemaLibraries/MetaLEX/metalex_mcontainerTypeBug.xsd Adds MetaLEX minimal repro schema for restriction/extension behaviour.
GeneratedSchemaLibraries/MetaLEX/metalex_mcontainerTypeBug_reproduce.ps1 Adds repro script for regenerating/building MetaLEX repro.
GeneratedSchemaLibraries/Libvirt/libosinfo.xsd Adds Libvirt-related XSD (relocated out of GelML resources).
GeneratedSchemaLibraries/LegalRuleML/normal/ruleml.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/LandXML/v1.2/LandXML-1.2.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/LandXML/v1.2/LandXML-1.2_enumListBug.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/LandXML/origin.md Adds provenance note for LandXML schemas.
GeneratedSchemaLibraries/HR-XML/origin.md Adds provenance and license pointer for HR-XML.
GeneratedSchemaLibraries/GS1/origin.md Adds provenance and licensing commentary for GS1 schemas.
GeneratedSchemaLibraries/GraffitiMarkupLanguage/origin.md Adds provenance note for GML spec-derived schema.
GeneratedSchemaLibraries/GraffitiMarkupLanguage/GraffitiMarkupLanguage.csproj Adds new schema library project for GML.
GeneratedSchemaLibraries/GraffitiMarkupLanguage/graffiti-markup-language_Version3.xsd Adds GML schema file.
GeneratedSchemaLibraries/GelML/origin.md Adds provenance note for GelML schemas.
GeneratedSchemaLibraries/GelML/GelML.csproj Removes embedded Libvirt XSD resources from GelML project.
GeneratedSchemaLibraries/GelML/GelML-v1_1candidate.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/EnzymeML/origin.md Adds provenance note for EnzymeML schemas.
GeneratedSchemaLibraries/EnzymeML/enzymeML.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/EnumsTest/EnumsTest.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/create individual xsd libraries.linq Updates helper script to add projects to the testing-suite slnf as well.
GeneratedSchemaLibraries/ContentModelTest/ContentModelTest.xsd-g.cs Adds generated types for new restriction/extension content-model test case.
GeneratedSchemaLibraries/ContentModelTest/ContentModelTest.xsd Adds new restriction-base/extension test schema for content generation.
GeneratedSchemaLibraries/Chem eStandards/OAGi_Chem_eStandards_5.3.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Chem eStandards/OAGi_Chem_eStandards_5.3_dayOfMonthBug.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Chem eStandards/OAGi_Chem_eStandards_5.3_contentBug.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/BasePropsTest/BasePropsTest.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/Atom/atom.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/AspNetSiteMaps/SiteMapSchema.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/SOAP-WSDL/wsdl20.xsd Adds WSDL 2.0 schema.
GeneratedSchemaLibraries/SOAP-WSDL/soap.xsd.config Adds schema config for SOAP/WSDL generation.
GeneratedSchemaLibraries/SOAP-WSDL/soap.xsd Adds SOAP adjunct schema.
GeneratedSchemaLibraries/SOAP-WSDL/SOAP-WSDL.csproj Adds new schema library project for SOAP-WSDL.
GeneratedSchemaLibraries/ALTO/origin.md Adds provenance note for ALTO schema copy.
GeneratedSchemaLibraries/ALTO/loc_xlink.xsd Adds XLink schema dependency for ALTO.
GeneratedSchemaLibraries/ALTO/ALTO.csproj Adds new schema library project for ALTO.
GeneratedSchemaLibraries/ALTO/alto-4-4.xsd.config Adds schema config for ALTO generation.
GeneratedSchemaLibraries/AkomaNtoso30-CSD13-D2f/schema/modular.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/AkomaNtoso/origin.md Adds provenance and spec references for Akoma Ntoso.
GeneratedSchemaLibraries/AbstractTypeTest/abstracttest.xsd-g.cs Regenerated output header update (tool version line).
GeneratedSchemaLibraries/1707_ISYBAU_XML_Schema/origin.md Adds provenance note for ISYBAU schema pack.
GeneratedSchemaLibraries/1707_ISYBAU_XML_Schema/1707-metadaten.xsd-g.cs Regenerated output header update (tool version line).
Review details

Suppressed comments (2)

XObjectsCode/Schema.cs:38

  • GetDependencies resolves imports using graph.Schema.Single(...) against import.Name, which will throw when schemaLocation contains a relative path or when the import isn't present in the graph. Normalise to Path.GetFileName and tolerate missing targets to avoid unexpected InvalidOperationExceptions during traversal.
    XObjectsCode/Schema.cs:113
  • IncludedByList assumes IncludedBy is non-null and calls IncludedBy.Split(...), but IncludedBy is optional and may be null. Accessing IncludedByList on schemas without an IncludedBy element will throw; the setter should also handle null/empty to clear the backing element.
  • Files reviewed: 122/129 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread XObjectsCode/Schema.cs Outdated
Comment thread XObjectsCode/Schema.cs
Comment thread XObjectsCode/Schema.cs
Comment thread GeneratedSchemaLibraries/XSD/W3C XMLSchema v1.xsd-g.cs Outdated
mamift and others added 8 commits September 15, 2026 13:32
Enhance null and whitespace handling for ImportedBy property.ImportedByList assumes ImportedBy is non-null and calls ImportedBy.Split(...), but ImportedBy is optional in the XImportGraph schema and may legitimately be null (as in the tests). Accessing ImportedByList on such a schema will throw; also the setter should tolerate null to clear the list.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
GetDependencies resolves includes using graph.Schema.Single(...) against include.Name, which will throw if the include uses a relative path (e.g. "./foo.xsd") or references a schema that isn't present in the graph. Normalising to Path.GetFileName and using FirstOrDefault (skipping missing targets) makes this resilient to common schemaLocation patterns.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…visited set (it always creates a new returnList), so any include/import cycle will recurse indefinitely (stack overflow). The unused locals (graph, countOfSkips) also suggest the intended visited-set logic was never wired up; this method needs to treat skipList as the accumulator/visited set and short-circuit already-seen schemas.
…ilation test passed: only change is version number.
@mamift
mamift merged commit e3c7ac4 into master Sep 15, 2026
5 checks passed
@mamift
mamift deleted the testing/gml branch September 15, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code gen edge case: when a XSD type uses string enums as the item type for an XSD List type, a bug occurs with enum generation

2 participants